package com.example.udpDemo;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.gateway.modules.entity.GatewayParam;
import org.jeecg.modules.gateway.modules.service.IGatewayParamService;
import org.jeecg.modules.gateway.protocolimpl.ProtocolService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


@Slf4j
@Service
public class ProtocolServiceImpl implements ProtocolService {

    public static final Map<String, String> PARAM_MAP = new ConcurrentHashMap<>();

    @Override
    public Boolean initLink() throws Exception {
        return ProtocolService.super.initLink();
    }

    @Override
    public List<GatewayParam> acquisitionParameter(List<GatewayParam> params) {
        params.forEach(gatewayParam -> gatewayParam.setParamValue(PARAM_MAP.get(gatewayParam.getKey())));
        return params;

    }


    @Override
    public Boolean controlParameter(List<GatewayParam> params) {
        log.info("无南向控制接口");
        return true;
    }

}
